/**
 * @Author @fiber-cloud
 * @Date 2025/9/4 19:54
 * 单例模式——饿汉模式
 */


//
class Singleton{
   //创建这个实例
    private static Singleton in = new Singleton();
    private Singleton(){}

    public static Singleton getIn(){
        return in;
    }
}


public class ThreadDemo10 {
    public static void main(String[] args) {
        Singleton s = Singleton.getIn();
        Singleton s2 = Singleton.getIn();

        //这里再new一个会报错
        // Singleton s3 = new Singleton();
        System.out.println(s == s2);
    }
}
